package org.xinjiang.data.migration.flush.convert;

import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.xinjiang.data.migration.flush.enums.*;
import org.xinjiang.data.migration.flush.utils.DefaultUtils;
import org.xinjiang.data.migration.hainan.entity.MstCommunityWorker;

import java.util.ArrayList;
import java.util.Collection;


/**
 * 社会工作者
 */
@Component
public class SocialWorkerConvert extends BaseConvert<org.xinjiang.data.migration.xinjiang.entity.SqjzGzry, MstCommunityWorker> {

    @Override
    public MstCommunityWorker convert(org.xinjiang.data.migration.xinjiang.entity.SqjzGzry gzry) {
        MstCommunityWorker worker = new MstCommunityWorker();
        worker.setSourceId(gzry.getId());
        worker.setXm(DefaultUtils.getName(gzry.getXingming()));
        worker.setXb(String.valueOf(SexEnum.sex(gzry.getXingbie()).getId().intValue()));
        worker.setCsrq(DefaultUtils.getDefCsrq(gzry.getChushengnianyue()));
        worker.setSfzh(DefaultUtils.getDefSfzh(gzry.getShenfenzhenghao()));//数据库非空
        worker.setZzmm(PoliticalOutlookEnum.toCode(gzry.getZhengzhimianmao()).getTargetCode());
        worker.setXl(EducationalLevelEnum.toCode(gzry.getXueli()).getTargetCode());
        worker.setZgxw(AcademicDegreeEnum.toCode(gzry.getZuigaoxuewei()).getTargetCode());
        worker.setZhy(SpecialityEnum.toCode(gzry.getZhiye()).getTargetCode());
        worker.setSsjg(gzry.getLuruJigou());
//        worker.setJzjgbm();没有
        worker.setZc(TitleEnum.toCode(gzry.getZhicheng()).getTargetCode());
        worker.setSfzz("1".equals(gzry.getShifouzaizhi()) ? "1" : "0");
        worker.setSj(gzry.getShouji());
        worker.setLxdh(gzry.getLianxidianhua());
        worker.setJtzz(DefaultUtils.getDefJtzz(gzry.getLianxidizhi()));//数据库非空
        worker.setQdhtrq(gzry.getHetongdate());
        worker.setHtq(ContractEnum.toCode(gzry.getHetongqiId()).getTargetCode());
        //更新人，更新时间，都没有
        worker.setCreateBy(gzry.getLuruId());
        worker.setCreateTime(gzry.getLts());
        return worker;
    }


    @Override
    public Collection<MstCommunityWorker> converts(Collection<org.xinjiang.data.migration.xinjiang.entity.SqjzGzry> ss) {
        Collection<MstCommunityWorker> collection = new ArrayList<>();
        if (CollectionUtils.isEmpty(ss)) {
            return collection;
        }
        for (org.xinjiang.data.migration.xinjiang.entity.SqjzGzry s : ss) {
            collection.add(convert(s));
        }
        return collection;
    }
}
